package com.sghd.football.net;

import com.sghd.common.socket.anno.InBody;
import com.sghd.common.socket.anno.InSession;
import com.sghd.common.socket.anno.SocketCommand;
import com.sghd.common.socket.anno.SocketModule;
import com.sghd.common.socket.core.ResultCallback;
import com.sghd.common.socket.session.Session;
import com.sghd.common.socket.session.SessionClose;
import com.sghd.common.socket.session.SessionOpen;
import com.sghd.football.module.game.facade.model.ConneReq;
import com.sghd.football.module.game.facade.model.JoinResult;

import java.util.Map;

import static com.sghd.common.socket.session.SessionKeys.IDENTITY;

/**
 * 游戏门面服务
 * 客户端入口
 */
@SocketModule
public interface ServerHandler extends SessionClose, SessionOpen {

    /**
     * 初始化连接
     * @param crypt true 启用报文解密{@link com.sghd.football.utils.CryptContext#decode(String)}
     */
    @SocketCommand(value = SocketEnum.CONN, crypt = true)
    void conn(Session session, ConneReq req);

    /**
     * 进入房间(JoinRoom)
     */
    @SocketCommand(SocketEnum.JOIN_ROOM)
    void enter(@InSession(IDENTITY) Long playerId, @InBody("configId") int configId, @InBody("gameId") int gameId,
               ResultCallback<JoinResult> callback);

    /**
     * 旋转操作
     */
    @SocketCommand(value = SocketEnum.OPERATRO, reply = SocketEnum.COMPLETE)
    Map<String, Object> operator(@InSession(IDENTITY) long playerId, @InBody("allBet") int betIdx);

}
